package DB;

import java.util.Vector;

import QueryHandler.Predicate;

public class EqualsSelection extends Predicate {
	
	private String toCompare;

/*
 * Constructor
 */
	
	public EqualsSelection(String field, String toCompare) {
		super(field);
		this.toCompare = toCompare;
	}

/*
 * @see QueryHandler.Predicate#checkPred(DB.Table, java.util.Vector)
 * 
 * Checks if the specific Predicate is satisfied by the tuple
 */
	@Override
	public boolean checkPred(Table table, Vector<String> tuple) {
		Vector<String> titles  = table.getTitles();
		int index = titles.indexOf(this.name);
		if (tuple.elementAt(index) != null)
			if (tuple.elementAt(index).indexOf(toCompare) >= 0){
				//System.out.println(tuple.elementAt(index));
				return true;
				
			}
		
		return false;
	}

}
